{% extends 'layout/basic.html' %}
{% load static %}

{% block title %} 用户登录 {% endblock %}


{% block css %}
    <link rel="stylesheet" href="{% static 'css/account.css' %}">
    <style>
        .error-msg {
            color: red;
            position: absolute;
            font-size: 13px;
        }
    </style>
{% endblock %}


{% block content %}
    <div class="account">
        <div class="title">用户登录</div>
        <form method="POST" novalidate>
            {% csrf_token %}
            {% for field in form %}
                {% if field.name == 'code' %}
                    <div class="form-group">
                        <label for="{{ field.id_for_label }}">{{ field.label }}</label>
                        <div class="row">
                            <div class="col-xs-7">
                                {{ field }}
                                <span class="error-msg">{{ field.errors.0 }}</span>
                            </div>
                            <div class="col-xs-5">
                                <img src="{% url 'web:image_code' %}" id="imageCode" title="点击更换图片">
                            </div>
                        </div>
                    </div>
                {% else %}
                    <div class="form-group">
                        <label for="{{ field.id_for_label }}">{{ field.label }}</label>
                        {{ field }}
                        <span class="error-msg">{{ field.errors.0 }}</span>
                    </div>
                {% endif %}
            {% endfor %}

        <div class="form-group">
            <label class="radio-inline">
        <input type="radio" name="options" id="optionsRadios3" value="dw" checked>单位登陆
    </label>
    <label class="radio-inline">
        <input type="radio" name="options" id="optionsRadios4"  value="gr">个人登陆
    </label>

        </div>



            <div>
              <div style="float: right;">
                    <a href="{% url 'web:login_sms' %}" style="text-decoration:none;">忘记密码？</a>
                </div>
                <div style="float: right;">&emsp;</div>
                  <div style="float: right;">
                    <a href="{% url 'web:login_sms' %}" style="text-decoration:none;">短信登录</a>
                </div>

            </div>

            <div class="row">



                <div class="col-xs-3">
                    <input type="submit" class="btn btn-primary" value="登  录"/>
                </div>


            </div>
        </form>
    </div>
{% endblock %}


{% block js %}
    <script>
        $(function () {
            $('#imageCode').click(function () {
                var oldSrc = $(this).attr('src');
                $(this).attr('src', oldSrc + "?");//给src重新加一个问号，他会自动请求
            })
        })
    </script>
{% endblock %}
